package com.irdstudio.apicenter.console.dm.appinfo;

import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.irdstudio.apicenter.console.dm.AppBaseInfo;
import com.irdstudio.apicenter.console.dm.AppBaseInfoDao;

@Service(value = "appBaseInfoService")
public class AppBaseInfoService {
	@Autowired
	private AppBaseInfoDao appBaseInfoDao;

	/**
	 * 根据条件获取app基础信息列表
	 * 
	 * @param sql
	 * @return
	 * @throws SQLException
	 * @throws ClassNotFoundException
	 */
	public List<AppBaseInfo> queryList(String sql) throws SQLException,
			ClassNotFoundException {

		return appBaseInfoDao.queryList(sql);

	}

	/**
	 * 根据应用 ID查询应用基本信息
	 * 
	 * @param appId
	 * @return
	 * @throws SQLException
	 */
	public AppBaseInfo findById(String appId) throws SQLException {
		return appBaseInfoDao.queryWithKeys(appId);
	}

	/**
	 * 新增信息
	 * 
	 * @param appBaseInfo
	 * @return
	 * @throws SQLException
	 * @throws ClassNotFoundException
	 */
	public int addAppBaseInfo(AppBaseInfo appBaseInfo) throws SQLException,
			ClassNotFoundException {

		return appBaseInfoDao.addAppBaseInfo(appBaseInfo);

	}

	/**
	 * 返回当前id在库中是否存在
	 * 
	 * @param appBaseInfo
	 * @return
	 * @throws SQLException
	 * @throws ClassNotFoundException
	 */
	public int findId(String id) throws SQLException, ClassNotFoundException {
		return appBaseInfoDao.findId(id);
	}

	/**
	 * 更新应用Svn信息
	 * 
	 * @param appId
	 * @return
	 */
	public boolean updateAppSvnInfo(String appId) {
		return appBaseInfoDao.updateAppSvnInfo(appId);
	}

	/**
	 * 更新应用信息
	 * 
	 * @param appId
	 * @return
	 */
	public String updateAppInfo(AppBaseInfo appBaseInfo) {
		return appBaseInfoDao.updateAppInfo(appBaseInfo);
	}

}
